﻿namespace EyeOpen.SilverlightConverter
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml.Linq;

    public partial class VisualStudioProject
    {
        public VisualStudioProject(string projectContent)
        {
            this.Process(projectContent);
        }

        private void Process(string projectContent)
        {
            this.projectXElement = XElement.Parse(projectContent);
            XElement importXElement =
                (from descendant in this.projectXElement.Descendants()
                 where descendant.Name.LocalName == "Import"
                 select descendant)
                .FirstOrDefault();

            this.isSilverlightLibrary = importXElement
                                            .Attribute("Project")
                                            .Value
                                            .EndsWith("Microsoft.Silverlight.CSharp.targets");
        }        
    }
}